package com.spiro.bintest;

import org.apache.thrift.TProcessorFactory;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.server.TNonblockingServer;
import org.apache.thrift.server.TServer;
import org.apache.thrift.transport.TNonblockingServerSocket;
import org.apache.thrift.transport.TNonblockingServerTransport;
import org.apache.thrift.transport.TTransportException;

import com.spiro.bintest.BinTest.Iface;

public class Server {
    public static void main(String[] args) {

        try {

            TProcessorFactory processor = new TProcessorFactory(
                    new BinTest.Processor<Iface>(new BinTestHandler()));
            TNonblockingServerTransport transport;
            transport = new TNonblockingServerSocket(9090);
            TServer server = new TNonblockingServer(
                    new TNonblockingServer.Args(transport).processorFactory(
                            processor).protocolFactory(
                            new TBinaryProtocol.Factory(true, true)));

            System.out.println("Starting the nonblocking server...");
            server.serve();

        } catch (TTransportException e) {
            e.printStackTrace();
        }

    }

}
